﻿namespace eeenno.SpeeedReaderUI.NativeWebBrowser.Threading
{
    using System;
    using System.Runtime.InteropServices;

    internal class NativeMethods
    {
        public const int ERROR_ALREADY_EXISTS = 0xb7;
        public const int EVENT_ALL_ACCESS = 3;
        public const int WAIT_FAILED = -1;
        public const int WAIT_TIMEOUT = 0x102;

        private NativeMethods()
        {
        }

        [DllImport("coredll.dll", SetLastError=true)]
        public static extern int CeGetThreadPriority(IntPtr hThread);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern bool CeSetThreadPriority(IntPtr hThread, int nPriority);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern bool CeSetThreadQuantum(IntPtr hThread, uint dwTime);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern bool CloseHandle(IntPtr hObject);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern IntPtr CreateMutex(IntPtr lpMutexAttributes, bool InitialOwner, string MutexName);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern IntPtr CreateSemaphore(IntPtr lpSemaphoreAttributes, int lInitialCount, int lMaximumCount, string lpName);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern bool EventModify(IntPtr hEvent, EVENT ef);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern int MsgWaitForMultipleObjectsEx(uint nCount, IntPtr[] lpHandles, uint dwMilliseconds, uint dwWakeMask, uint dwFlags);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern IntPtr OpenEvent(int dwDesiredAccess, bool bInheritHandle, string lpName);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern IntPtr OpenSemaphore(int desiredAccess, bool inheritHandle, string name);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern bool ReleaseMutex(IntPtr hMutex);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern bool ReleaseSemaphore(IntPtr handle, int lReleaseCount, out int previousCount);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern uint ResumeThread(IntPtr hThread);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern uint SuspendThread(IntPtr hThread);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern bool TerminateThread(IntPtr hThread, int dwExitCode);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern bool TerminateThread(uint hThread, int dwExitCode);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern int WaitForMultipleObjects(uint nCount, IntPtr[] lpHandles, bool fWaitAll, uint dwMilliseconds);
        [DllImport("coredll.dll", SetLastError=true)]
        public static extern int WaitForSingleObject(IntPtr hHandle, int dwMilliseconds);

        public enum EVENT
        {
            PULSE = 1,
            RESET = 2,
            SET = 3
        }
    }
}

